package com.company.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.company.common.annotation.Log;
import com.company.common.core.controller.BaseController;
import com.company.common.core.domain.AjaxResult;
import com.company.common.enums.BusinessType;
import com.company.system.domain.TablePersontrain;
import com.company.system.service.ITablePersontrainService;
import com.company.common.utils.poi.ExcelUtil;
import com.company.common.core.page.TableDataInfo;

/**
 * 员工培训Controller
 * 
 * @author company
 * @date 2022-07-09
 */
@RestController
@RequestMapping("/system/persontrain")
public class TablePersontrainController extends BaseController
{
    @Autowired
    private ITablePersontrainService tablePersontrainService;

    /**
     * 查询员工培训列表
     */
    @PreAuthorize("@ss.hasPermi('system:persontrain:list')")
    @GetMapping("/list")
    public TableDataInfo list(TablePersontrain tablePersontrain)
    {
        startPage();
        List<TablePersontrain> list = tablePersontrainService.selectTablePersontrainList(tablePersontrain);
        return getDataTable(list);
    }

    /**
     * 导出员工培训列表
     */
    @PreAuthorize("@ss.hasPermi('system:persontrain:export')")
    @Log(title = "员工培训", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TablePersontrain tablePersontrain)
    {
        List<TablePersontrain> list = tablePersontrainService.selectTablePersontrainList(tablePersontrain);
        ExcelUtil<TablePersontrain> util = new ExcelUtil<TablePersontrain>(TablePersontrain.class);
        util.exportExcel(response, list, "员工培训数据");
    }

    /**
     * 获取员工培训详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:persontrain:query')")
    @GetMapping(value = "/{persionid}")
    public AjaxResult getInfo(@PathVariable("persionid") Long persionid)
    {
        return AjaxResult.success(tablePersontrainService.selectTablePersontrainByPersionid(persionid));
    }

    /**
     * 新增员工培训
     */
    @PreAuthorize("@ss.hasPermi('system:persontrain:add')")
    @Log(title = "员工培训", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TablePersontrain tablePersontrain)
    {
        return toAjax(tablePersontrainService.insertTablePersontrain(tablePersontrain));
    }

    /**
     * 修改员工培训
     */
    @PreAuthorize("@ss.hasPermi('system:persontrain:edit')")
    @Log(title = "员工培训", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TablePersontrain tablePersontrain)
    {
        return toAjax(tablePersontrainService.updateTablePersontrain(tablePersontrain));
    }

    /**
     * 删除员工培训
     */
    @PreAuthorize("@ss.hasPermi('system:persontrain:remove')")
    @Log(title = "员工培训", businessType = BusinessType.DELETE)
	@DeleteMapping("/{persionids}")
    public AjaxResult remove(@PathVariable Long[] persionids)
    {
        return toAjax(tablePersontrainService.deleteTablePersontrainByPersionids(persionids));
    }
}
